package kongkong;

import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * 加载弹窗
 * @author 53045
 *
 */
public class LoadingDialog {
    private final Stage dialog;

    public LoadingDialog(Stage primaryStage) {
//    	dialog = new Stage();
//    	Label label = new Label("正在加载请稍后...");
//    	label.setTextFill(Color.BLUE);
//        Scene scene = new Scene(label, 400, 100);
//        dialog.setScene(scene);
    	
        dialog = new Stage();
        ProgressIndicator progressIndicator = new ProgressIndicator();
        dialog.initOwner(primaryStage);
        dialog.initStyle(StageStyle.UNDECORATED);
        dialog.initStyle(StageStyle.TRANSPARENT);
        dialog.initModality(Modality.APPLICATION_MODAL);
        Label label = new Label("数据加载中, 请稍后...");
        label.setTextFill(Color.BLUE);
        progressIndicator.setProgress(-1F);
        VBox vBox = new VBox();
        vBox.setSpacing(10);
        vBox.setBackground(Background.EMPTY);
        vBox.getChildren().add(progressIndicator);
        vBox.getChildren().add(label);
        Scene scene = new Scene(vBox, 400, 200);
        scene.setFill(null);
        dialog.setScene(scene);
    }

    public void activate() {
//    	System.out.println(">>>>>>>>>>>>启动加载>>>>>>>>>>>>"+dialog);
        dialog.show();
    }

    public void cancel() {
//    	System.out.println(">>>>>>>>>>>>取消加载>>>>>>>>>>>>"+dialog);
        dialog.close();
    }
}
